:- module(main,[main/0]).
:- use_module(token).
:- use_module(parse).
:- use_module(write).
:- use_module(compile).

main :- query(Term, Variables), execute_term(Term, Variables), main.

query(Term, Variables) :- write_string("?~ "), read_line(Line),
 tokenize(Tokens, Line, "."), term(IR, Tokens, []), pl_and_ir(Term, IR, [], Variables).

execute_term(Term, Variables) :- call(Term),
 (Variables=[] -> write_string("yes."),nl ; display_variables(Variables) ),
 read_character(More), More \= 0';.
execute_term(_,_) :- write_string("no."),nl.

display_variables([]).
display_variables([Eq|Eqs]) :- '$foo$write'(Eq), nl, display_variables(Eqs).
